package com.example.user.controller;

import cn.hutool.core.lang.UUID;
import cn.hutool.json.JSONUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description TODO
 * @Author JFeng
 * @Date 2024/4/19
 */

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("/add")
    public Object add() {
        ResponseEntity<Object> response = restTemplate.getForEntity("http://localhost:8081/stock/reduce", Object.class);
        Map<Object, Object> map = new HashMap<>();
        map.put("stockService", response);
        map.put("orderService", UUID.fastUUID().toString());
        return JSONUtil.toJsonStr(map);
    }


}
